package org.summerframework.component.security.core.service;

import org.summerframework.component.security.LoginData;
import org.summerframework.component.security.enumeration.LoginTypeEnum;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


/**
 * 登录service
 *
 * @author 石超
 * @version v1.0.0
 */
public interface LoginService {


    ThreadLocal<LoginData> CURR_LOGIN_DATA = ThreadLocal.withInitial(LoginData::new);

    /**
     * 获取登录信息
     *
     * @return 登录信息 {@link LoginData}
     */
    LoginData setLoginContext();

    /**
     * 完成登录
     */
    @Transactional(rollbackFor = Exception.class)
    void finishLogin();

    /**
     * 处理LoginTypeEnum的能力 {@link LoginTypeEnum}
     *
     * @return 处理LoginTypeEnum的能力的列表
     */
    List<Integer> hasParseLoginType();

    /**
     * 更新登录失败次数
     *
     * @param loginFailed 是否成功
     */
    @Transactional(rollbackFor = Exception.class)
    void updateFailCount(boolean loginFailed);
}
